<template>
  <div>
    <div class="list-btn">
      姓名:<Input v-model.trim="params.realname" placeholder="请输入姓名" style="width: 200px" clearable @keyup.enter.native="getList(url)" />
    </div>
    <div class="list-btn">
      手机号:<Input v-model.trim="params.phone" placeholder="请输入手机号" style="width: 200px" clearable @keyup.enter.native="getList(url)" />
    </div>
    <div class="list-btn">
      订单号:<Input v-model.trim="params.nid" placeholder="请输入订单号" style="width: 200px" clearable @keyup.enter.native="getList(url)" />
    </div>
    <div class="list-btn">
      还款时间:<DatePicker type="date" @on-change="startTime"  placeholder="选择开始时间" style="width: 200px"></DatePicker>
      ～<DatePicker type="date" @on-change="endTime"  placeholder="选择结束时间" style="width: 200px" ></DatePicker>
    </div>
    <div class="list-btn">
      <Button type="primary" @click="getList(url,'refresh')">搜索</Button>
    </div>
    <page-list :listTitle="listTitle" :list="list" :loading="loading" @selectItem="ids = $event;"></page-list>
    <page-button :total="total" @changePageNum="params.pageCurrent = $event; getList(url)" @changePageSize="params.pageLimit = $event; getList(url)"></page-button>
  </div>
</template>

<script>
  import listMixin from '../../mixin/list'
  import pageList from '../../template/listTemplate'
  import pageButton from '../../template/pageBtnTemplate'
  import confirmDialog from '../../template/confirmDialogTemplate'
  export default {
    mixins:[listMixin],
    components: {
      pageList,
      pageButton,
      confirmDialog
    },
    data () {
      return {
        tag: {
          'title': '收款流水',
          'path': '/work/receipt/list'
        },
        listTitle: [
          {
            title: '订单号',
            minWidth: 180,
            key: 'nid',
            align:'left',
          },
          {
            title: '还款时间',
            key: 'resultTime',
            minWidth:150,
            align:'center',
            render : (h,params) => {
              return h('div',this.getLocalTime(params.row.resultTime))
            }
          },
          {
            title: '姓名',
            key: 'realname',
            minWidth:80,
            align:'center'
          },
          {
            title: '手机号',
            key: 'phone',
            minWidth:120,
            align:'center'
          },
          {
            title: '借款金额(元)',
            key: 'loanMoney',
            minWidth:120,
            align:'center',
             render:(h,params) => {
              return h('div',this.toYuan(params.row.loanMoney))
            }
          },
          {
            title: '实放金额(元)',
            key: 'realMoney',
            minWidth:120,
            align:'center',
            render:(h,params) => {
              return h('div',this.toYuan(params.row.realMoney))
            }
          },
          {
            title: '还款银行名称',
            key: 'bankName',
            minWidth:130,
            align:'center'
          },
          {
            title: '还款银行卡尾号',
            key: 'bankCardlast',
            minWidth:140,
            align:'center',

          },
          {
            title: '流水号',
            key: 'requestno',
            minWidth:250,
            align:'center',
            render : (h,params) => {
              return h('div',params.row.status == 1?params.row.requestno : '—')
            }
          },
          {
            title: '还款通道',
            key: 'lendingChannel',
            minWidth:120,
            align:'center',
            render : (h,params) => {
               return h('div',this.getType(params.row.lendingChannel,'lendingChannel'))
            }
          },
          {
            title: '还款金额(元)',
            key: 'repayMoney',
            minWidth:120,
            align:'center',
             render:(h,params) => {
              return h('div',this.toYuan(params.row.repayMoney))
            }
          },
          {
            title: '还款类型',
            key: 'repayType',
            minWidth:120,
            align:'center',
            render: (h,params) => {
              let type = '';
              switch(params.row.repayType){
                case 1:
                  type = '正常还款';
                  break;
                case 2:
                  type = '延期';
                  break;
                case 3:
                  type = '减免';
                  break;
              }
              return h('div',type)
            }
          },
          {
            title: '状态',
            key: 'status',
            minWidth:120,
            align:'center',
            render: (h,params) => {
              let type = '';
              let color = '';
              switch(params.row.status){
                case 1:
                  type = '还款成功';
                  color='#19be6b';
                  break;
                case 2:
                  type = '还款失败';
                  color = '#ed4014';
                  break;
                case 3:
                  type = '处理中';
                  color = "#f90";
                  break;
              }
              return h('div',{
                style:{
                  color:color
                }
              },type)
            }
          },

        ],
        url: '/userRepayment/list',
        nameListUrl: '',
        params: {
          pageCurrent: 1,
          pageLimit: 10
        },

      }
    },
  }
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
  .list-btn{
    margin-bottom: 5px;
    margin-right: 5px;
    display: inline-block;
  }
  .refresh-btn{
    float: right;
  }

</style>
